#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>
//#include<arpa/inet.h>
//#include<netdb.h>

int main(int argc,char* argv[])
{
    int sockfd,numbytes;
    char buf[BUFSIZ];
    printf("%d\n",BUFSIZ);
    struct sockaddr_in my_sock;
    while(( sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1);
    printf("we get the sockfd!\n");
    my_sock.sin_family = AF_INET;
    my_sock.sin_port = htons(8000);
    my_sock.sin_addr.s_addr = inet_addr("10.10.1.45");
    bzero(&(my_sock.sin_zero),8);
    
    while(connect(sockfd,(struct sockaddr*)&my_sock,sizeof(struct sockaddr))==-1);
    printf("get the server!\n");
    numbytes = recv(sockfd,buf,BUFSIZ,0);
    buf[numbytes] = '\0';
    printf("%s\n",buf);
    while(1)
    {
        printf("Enter something:\n");
        scanf("%s",buf);
        numbytes = send(sockfd,buf,strlen(buf),0);
        numbytes = recv(sockfd,buf,BUFSIZ,0);
        buf[numbytes] = '\0';
        printf("receive:%s\n",buf);
        
    }

    close(sockfd);
    
    return 0;
}
